<?php

namespace app\index\model;

use think\Model;

class Region extends Model
{
    // 设置当前模型对应的完整数据表名称
    protected $table = 'xb_admin_area';

    //返回下级区域 sky
    public function getRegion($pid)
    {
        $list = array();
        
        if($pid==="") return $list;

        $where = [
            'pid' => $pid,
            'status' => 1
        ];
        $list = $this->where($where)->order('listorder asc')->select();
        $list = $list ? collection($list)->toArray() : array();
        return $list;
    }

    //返回所有区域 sky
    public function getAll()
    {
        $data = array();
        $list = self::all();
        foreach($list as $d)
        {
            $k = $d['id'];
            $data[$k] = $d->getData();
        }
        return $data;
    }
    
}